import { Request, Response, NextFunction } from "express";
import { uploadAliOss } from "@/services/ali-oss-client";

export default async (request: Request, response: Response, next: NextFunction) => {
	try {
		if (request.files && request.files.length) {
			const file = (request.files as unknown as Express.Multer.File[])[0];
			const path = await uploadAliOss(file);
			response.json({ data: { path }, message: "成功" });
		}
	} catch (error) {
		next(error);
	}
};
